/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.isd.global.modelo;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 *
 * @author ctrosch
 */
@Entity
@Table(name="GRTPAC")
public class CodigoPostal implements Serializable {
    private static final long serialVersionUID = 1L;

    @EmbeddedId
    private CodigoPostalPK id;

    @Column(name="GRTPAC_CODPOS", length=10)
    private String codpos;

    @Column(name="GRTPAC_DESCRP", length=60)
    private String descrp;

    @JoinColumn(name = "GRTPAC_CODPAI", referencedColumnName = "GRTPAH_CODPAI", nullable = false, insertable=false, updatable=false)
    @ManyToOne(optional = false)
    private Pais pais;

    @JoinColumns({
        @JoinColumn(name = "GRTPAC_PAIPRO", referencedColumnName = "GRTPAI_CODPAI", nullable = false, insertable=false, updatable=false),
        @JoinColumn(name = "GRTPAC_CODPRO", referencedColumnName = "GRTPAI_CODPRO", nullable = false, insertable=false, updatable=false)
    })
    @ManyToOne(optional = false)
    private Provincia provincia;

    public String getCodpos() {
        return codpos;
    }

    public void setCodpos(String codpos) {
        this.codpos = codpos;
    }

    public String getDescrp() {
        return descrp;
    }

    public void setDescrp(String descrp) {
        this.descrp = descrp;
    }

    public CodigoPostalPK getId() {
        return id;
    }

    public void setId(CodigoPostalPK id) {
        this.id = id;
    }

    public Pais getPais() {
        return pais;
    }

    public void setPais(Pais pais) {
        this.pais = pais;
    }

    public Provincia getProvincia() {
        return provincia;
    }

    public void setProvincia(Provincia provincia) {
        this.provincia = provincia;
    }

    

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CodigoPostal)) {
            return false;
        }
        CodigoPostal other = (CodigoPostal) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "tv.global.modelo.CodigoPostal[id=" + id + "]";
    }

}
